package com.example.shiro;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;

import com.example.utils.Message;
import org.apache.shiro.web.filter.authc.UserFilter;

import com.alibaba.fastjson.JSON;

public class ShiroUserFilter extends UserFilter {

    @Override
    protected void redirectToLogin(ServletRequest servletRequest, ServletResponse servletResponse) throws IOException {
        // 返回json
        servletResponse.setContentType("application/json; charset=utf-8");
        Message message = new Message(999,"未登录！","");
        String json = JSON.toJSONString(message);
        servletResponse.getWriter().write(json);
    }

}